package com.lhkj.ct.meta.modules.patient.service.impl;

import com.lhkj.ct.base.enums.PatSourceEnum;
import com.lhkj.ct.meta.modules.patient.model.entity.TblPatSource;
import com.lhkj.ct.meta.modules.patient.mapper.TblPatSourceMapper;
import com.lhkj.ct.meta.modules.patient.service.PatSourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 档案来源 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2023-12-15
 */
@Service
public class PatSourceServiceImpl extends ServiceImpl<TblPatSourceMapper, TblPatSource> implements PatSourceService {

    @Override
    public List<Map<String, Object>> countBySourceType(PatSourceEnum[] patSources) {
        return getBaseMapper().countBySourceType(patSources);
    }

    @Override
    public boolean saveBatch(Collection<TblPatSource> entityList) {
        // 插入档案数据
        String sqlStatement = "com.lhkj.ct.meta.modules.patient.mapper.TblPatSourceMapper.insertOnDuplicate";
        return executeBatch(entityList, DEFAULT_BATCH_SIZE, (sqlSession, entity) -> sqlSession.insert(sqlStatement, entity));
    }

    @Override
    public int insertOnDuplicate(TblPatSource patSource) {
        return getBaseMapper().insertOnDuplicate(patSource);
    }
}
